package com.jrx.anytxn.param.controller.aviator;

import com.jrx.anytxn.i18n.annotation.IgnoreConvertField;
import com.jrx.anytxn.i18n.response.TxnRespResult;
import com.jrx.anytxn.common.exception.TxnException;
import com.jrx.anytxn.param.service.aviator.IRuleResultService;
import com.jrx.anytxn.param.entity.RuleSelect;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jrx.auth.filter.service.InfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;

/**
 * 结果集的的管理
 *
 * @author Qingyao Xing
 * @date 2019/7/17 13:48
 */
@Api(tags = "结果集的查询管理")
@RestController
@RequestMapping("/param/rule/result")
public class RuleResultController {

    @Autowired
    private IRuleResultService iRuleResultService;
    @Autowired
    private InfoService infoService;

    @ApiOperation(value = "结果集的下拉列表查询", notes = "结果集的下拉列表查询")
    @GetMapping(value = "/viewDetail/{tableName}/{organizationId}/{tableType}")
    @IgnoreConvertField
    public TxnRespResult<HashMap<String, List<RuleSelect>>> getRuleSelectList(@PathVariable String tableName, @PathVariable String organizationId,@PathVariable String tableType) throws TxnException {
        String tenantId= String.valueOf(infoService.getUser().getProjectId());
        return iRuleResultService.getRuleMap(tableName, organizationId,tenantId,tableType);
    }
}
